﻿using System;
using System.Collections.ObjectModel;
using System.Linq;
using Unread.App.Services;
using Unread.App.ViewModels;

namespace Unread.App.Views
{
    public class DesignDataContext
    {
        public DesignDataContext()
        {
            LoadUnreadViewModel();
            LoadFeedItemViewModel();
            LoadManageFeedsModel();
        }

        #region AddFeedViewModel

        public string Url { get { return "http://redlettermedia.com/feed"; } }
        public string ErrorMessage { get { return "An error has occurred."; } }

        #endregion

        #region UnreadViewModel

        public ObservableCollection<UnreadFeedViewModel> Feeds { get; set; }

        private void LoadUnreadViewModel()
        {
            Feeds = new ObservableCollection<UnreadFeedViewModel>();

            var viewModel = new UnreadFeedViewModel(new NavigationService()) { FeedId = Guid.NewGuid(), Title = "Feed 1" };
            viewModel.UnreadItems.Add(new UnreadFeedItemViewModel
            {
                FeedItemId = Guid.NewGuid(), Title = "Item 1", Subtitle = "This is item one.", PublishDate = DateTime.Now
            });
            viewModel.UnreadItems.Add(new UnreadFeedItemViewModel
            {
                FeedItemId = Guid.NewGuid(),
                Title = "Item 2",
                Subtitle = "<b>This</b> is <u>item two</u>.",
                PublishDate = DateTime.Now
            });
            viewModel.UnreadItems.Add(new UnreadFeedItemViewModel
            {
                FeedItemId = Guid.NewGuid(),
                Title = "Item 3",
                Subtitle = "This is item three and its subtitle is long long long long long long long long long long long long long long long long long long long .",
                PublishDate = DateTime.Now.AddDays(7)
            });
            viewModel.UnreadItems.Add(new UnreadFeedItemViewModel
            {
                FeedItemId = Guid.NewGuid(),
                Title = "Item 4",
                Subtitle = "This is item four.",
                PublishDate = DateTime.Now.AddMonths(1)
            });
            viewModel.UnreadItems.Add(new UnreadFeedItemViewModel
            {
                FeedItemId = Guid.NewGuid(),
                Title = "Item 5",
                Subtitle = "This is item five.",
                PublishDate = DateTime.Now.AddYears(1)
            });
            viewModel.UnreadItems.Add(new UnreadFeedItemViewModel
            {
                FeedItemId = Guid.NewGuid(),
                Title = "Item 6",
                Subtitle = "This is item six.",
                PublishDate = DateTime.Now.AddYears(1)
            });

            Feeds.Add(viewModel);
        }

        #endregion

        #region FeedItemViewModel

        public string Title { get { return "Feed title"; } }

        public ObservableCollection<ItemViewModel> Items { get; set; }

        private void LoadFeedItemViewModel()
        {

            Items = new ObservableCollection<ItemViewModel>();
            Items.Add(new ItemViewModel
            {
                Title = "Item title",
                Subtitle = "the subtitle!",
                Content = "He's right behind me, isn't he."
            });
        }

        #endregion

        #region ManageFeedsViewModel

        public FeedViewModel SelectedFeed { get { return FeedOverview.First(); } }
        public ObservableCollection<FeedViewModel> FeedOverview { get; set; }

        private void LoadManageFeedsModel()
        {
            FeedOverview = new ObservableCollection<FeedViewModel>();

            FeedOverview.Add(new FeedViewModel { Title = "Feed 1", Subtitle = "number one", Image = "ms-appx:///Assets/Logo.png" });
            FeedOverview.Add(new FeedViewModel { Title = "Feed 2", Subtitle = "number two", Image = "ms-appx:///Assets/Logo.png" });
            FeedOverview.Add(new FeedViewModel { Title = "Feed 3", Subtitle = "number three", Image = "ms-appx:///Assets/Logo.png" });
        }

        #endregion
    }
}
